//
//  LPFeedbackQuestionViewController.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 17/5/12.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPFeedbackQuestionViewController.h"
#import "MyICRemarkView.h"
@interface LPFeedbackQuestionViewController ()
/** 备注 */
@property (nonatomic, strong) MyICRemarkView *remarkView;
/** 申请 */
@property (nonatomic, strong) UIButton *claim;
@end

@implementation LPFeedbackQuestionViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.titlelabel.text = @"问题反馈";
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.remarkView];
    [self.view addSubview:self.claim];
}


- (void)action_claim{
    if (self.remarkView.textView.text.length > 0) {//
        [self netWorking_question];
    }else{
        [YJProgressHUD showMessage:@"请输入内容" inView:self.view];
    }
}
///问题反馈
- (void)netWorking_question{
    __weak typeof(self) weakSelf = self;
    [YJProgressHUD showMessage:@"提交中..." duration:10 view:self.view];
    //当前版本号
      NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    //手机型号
    NSString* phoneModel = [[UIDevice currentDevice] localizedModel];
    //手机系统版本
    NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];
    NSDictionary *REMAKER = @{@"appVersion":currentVersion,
                              @"phoneVersion":phoneVersion,
                              @"phoneModel":phoneModel};
    
    NSDictionary *dict = @{@"ACCOUNTID":ZJUSERINFORMODEL.ORG_ACCOUNT.ID,
                           @"MOBILE":ZJUSERINFORMODEL.ORG_ACCOUNT.MOBILE,
                           @"CONTENT":self.remarkView.textView.text,
                           @"REMAKER":REMAKER};
    [NetWorkingManager postWithUrlString:[NetWorkingURL dsactionAppError] Parameter:dict Success:^(id object) {
        [YJProgressHUD hide];
        NetWorkModel *model = [NetWorkModel yy_modelWithJSON:object];
        if ([model.STATE isEqualToString:@"20000"]) {
             [YJProgressHUD showMessage:@"提交成功" inView:weakSelf.view];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [weakSelf.navigationController popViewControllerAnimated:YES];
            });
        }else{
         [YJProgressHUD showMessage:@"提交失败" inView:weakSelf.view];
        }
    } Fail:^(id object) {
        [YJProgressHUD showMessage:@"提交失败" inView:weakSelf.view];
    }];
}

#pragma mark - Setter


#pragma mark - Getters
- (MyICRemarkView *)remarkView{
    if (_remarkView == nil){
        _remarkView = [[MyICRemarkView alloc]initWithFrame:CGRectMake(0, navHeight , self.view.width, 200 * [UIScreen zj_screenHScale]) title:@""];
        _remarkView.backgroundColor = [UIColor clearColor];
    }
    return _remarkView;
}

- (UIButton *)claim{
    if (_claim == nil){
        _claim = [[UIButton alloc] initWithFrame:CGRectMake(35 * [UIScreen zj_screenWScale], self.view.height - 88 * [UIScreen zj_screenHScale], self.view.width - 70 * [UIScreen zj_screenWScale], 44 * [UIScreen zj_screenHScale])];
        _claim.backgroundColor = [UIColor themeColor];
        _claim.centerY = self.view.centerY;
        [_claim setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_claim setTitle:@"提交" forState:UIControlStateNormal];
        [_claim addTarget:self action:@selector(action_claim) forControlEvents:UIControlEventTouchUpInside];
        _claim.layer.cornerRadius = 4 * [UIScreen zj_screenWScale];
    }
    return _claim;
}


@end
